﻿Imports System.Data.SqlClient

Public Class FrmSocioWithDataGridView

    Private Sub SocioBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles SocioBindingNavigatorSaveItem.Click
        If Me.Validate() Then
            Try
                Me.SocioBindingSource.EndEdit()
                Me.TableAdapterManager.UpdateAll(Me.VideoDataSet)
            Catch ex As DBConcurrencyException
                MessageBox.Show("Error de concurrencia. Los datos que usted quiere modificar ya han sido modificados", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Me.SocioTableAdapter.Fill(Me.VideoDataSet.Socio)
            Catch ex As DataException
                MessageBox.Show("Datos inválidos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                SocioBindingSource.CancelEdit()
            Catch ex As SqlException
                MessageBox.Show("Ha ocurrido un error con el servidor de la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If
    End Sub

    Private Sub FrmSocioWithDataGridView_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try
            Me.SocioTableAdapter.Fill(Me.VideoDataSet.Socio)
        Catch ex As SqlException
            MessageBox.Show("Ha ocurrido un error con el servidor de la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub SocioDataGridView_DataError(sender As System.Object, e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles SocioDataGridView.DataError
        MessageBox.Show("Error en la fila " & e.RowIndex & ", columna " & e.ColumnIndex)
    End Sub
End Class